<?php

    // +----------------------------------------------------------------------
    // | Seo模型
    // +----------------------------------------------------------------------
    // | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
    // +----------------------------------------------------------------------
    // | Author: 微尘 <yicmf@qq.com>
    // +----------------------------------------------------------------------

    namespace app\common\model;


    class Seo extends Common
    {

		/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeInsert($data)
		{
			$data['status'] = 1;
		}

		/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeWrite($data)
		{
			$data['matching_degree'] = '';
		}

        /**
         * 计算当前级别
         * @param $value
         * @param $data
         * @return int
         */
        protected function setMatchingDegreeAttr($value, $data): int
		{
            $sum = 0;
            foreach ($data as $key => $temp) {
                if (in_array($key, ['module', 'controller', 'action']) && trim($temp)) {
                    $sum++;
                }
            }
            return $sum;
        }
    }
